#include "GameApp.h"
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
#endif
 
extern "C" {
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
    INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
#else
    int main(int argc, char *argv[])
#endif
    {
		//allocating a new console and rerouting cout to it.
		AllocConsole();
		AttachConsole(GetCurrentProcessId());
		std::streambuf *backup = std::cout.rdbuf();
		std::ofstream console_out("CONOUT$");
		std::cout.rdbuf(console_out.rdbuf());

        // Create application object
        gpApp = new GameApp();
 
		// Initialize the application
		gpApp->initApp();		// try-catch block!

		// Start the application loop
		gpApp->startApp();		// try-catch block!

		delete(gpApp);

        return 0;			// maybe app.getExitCode()
    }
}